package cool.tianyou.blue.bird.common.util;


import cool.tianyou.blue.bird.common.model.entity.LoginUserInfo;

/**
 * AuthUtil
 *
 * @author likeguo
 */
public class AuthUtil {

    private static final ThreadLocal<LoginUserInfo> THREAD_LOCAL = new InheritableThreadLocal<>();

    /**
     * 设置当前登录用户
     *
     * @param user user
     */
    public static void setLoginUser(LoginUserInfo user) {
        THREAD_LOCAL.set(user);
    }

    /**
     * 获取当前登录用户
     *
     * @return user
     */
    public static LoginUserInfo getLoginUser() {
        return THREAD_LOCAL.get();
    }

    /**
     * 释放当前登录用户信息
     *
     */
    public static void close()  {
        THREAD_LOCAL.remove();
    }

    private AuthUtil() {

    }

}
